home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE15 / CPPCLASS / OWLDEL / OWLCTRL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-21  |  3.5 KB  |  171 lines

  1. #include "owlctrl.h"
  2.  
  3. TOWLDelphiControl::TOWLDelphiControl()
  4. {
  5.   InsertOWLControl(NULL);
  6. };
  7.  
  8. void TOWLDelphiControl::InsertOWLControl(TWindow *IControl)
  9. {
  10.     InternalControl   = IControl;
  11.     FDispatchEvent.Code = NULL;
  12. };
  13.  
  14. unsigned long TOWLDelphiControl::DoDispatch(uint Msg, WPARAM wp, LPARAM lp)
  15. {
  16.   if (FDispatchEvent.Code != NULL)
  17.     ((TDispatchEvent)FDispatchEvent.Code)(FDispatchEvent.Self, Msg, wp, lp );
  18.   return 0;
  19. };
  20.  
  21. TOWLDelphiControl::~TOWLDelphiControl()
  22. {
  23.   if (InternalControl != NULL)
  24.       delete InternalControl;
  25.       InternalControl = NULL;
  26. };
  27.  
  28. void TOWLDelphiControl::DoNotifyEvent(TEvent AnEvent)
  29. {
  30.   if (AnEvent.Code != NULL)
  31.         ((TCPPNotifyEvent)AnEvent.Code)(AnEvent.Self,(const void *)this);
  32. };
  33.  
  34. void   TOWLDelphiControl::SetOnMessage(TEvent func)
  35. {
  36.   FDispatchEvent = func;
  37. };
  38.  
  39. void   TOWLDelphiControl::SetVisible(bool aValue)
  40. {
  41.  if (InternalControl != NULL)
  42.  {
  43.     if (!InternalControl->IsWindow())
  44.       InternalControl->Create();
  45.  
  46.     if (aValue)
  47.       InternalControl->Show(SW_SHOW);
  48.     else
  49.       InternalControl->Show(SW_HIDE);
  50.  }
  51. }
  52.  
  53. bool   TOWLDelphiControl::GetVisible()
  54. {
  55.     if (InternalControl != NULL)
  56.       return (bool) InternalControl->IsWindowVisible();
  57.     return false;
  58. }
  59.  
  60. void   TOWLDelphiControl::SetEnabled(bool avalue)
  61. {
  62.     if (InternalControl != NULL)
  63.       InternalControl->EnableWindow(avalue);
  64. }
  65.  
  66. bool   TOWLDelphiControl::GetEnabled()
  67. {
  68.     if (InternalControl != NULL)
  69.      InternalControl->IsWindowEnabled();
  70.      return false;
  71. }
  72.  
  73.  void   TOWLDelphiControl::BringToFront()
  74. {
  75.   if (InternalControl != NULL)
  76.   InternalControl->BringWindowToTop();
  77. }
  78.  
  79.  TPoint   TOWLDelphiControl::ClientToScreen( TPoint pt )
  80. {
  81.  if (InternalControl != NULL)
  82.   InternalControl->ClientToScreen( pt );
  83.  return pt;
  84. }
  85.  
  86.  int   TOWLDelphiControl::GetTextBuf( LPSTR Buff, int Len )
  87. {
  88.     if (InternalControl != NULL)
  89.      return InternalControl->GetWindowText( Buff, Len );
  90.     else
  91.      return 0;
  92. }
  93.  
  94.  int   TOWLDelphiControl::GetTextLen()
  95. {
  96.   if (InternalControl != NULL)
  97.      return InternalControl->GetWindowTextLength();
  98.   else
  99.      return 0;
  100. }
  101.  
  102.  void   TOWLDelphiControl::Hide()
  103. {
  104.   if (InternalControl != NULL)
  105.     InternalControl->Show( SW_HIDE );
  106. }
  107.  
  108.  void   TOWLDelphiControl::Invalidate()
  109. {
  110.  if (InternalControl != NULL)
  111.   InternalControl->Invalidate( true );
  112. }
  113.  
  114.  void   TOWLDelphiControl::Refresh()
  115. {
  116.   if (InternalControl != NULL)
  117.   {
  118.      InternalControl->Invalidate( true );
  119.      InternalControl->UpdateWindow();
  120.   }
  121. }
  122.  
  123.  void   TOWLDelphiControl::ScrollBy( int DeltaX, int DeltaY )
  124. {
  125.   if (InternalControl != NULL)
  126.   InternalControl->ScrollWindow( DeltaX, DeltaY );
  127. }
  128.  
  129.  void   TOWLDelphiControl::Repaint()
  130. {
  131.   if (InternalControl != NULL)
  132.   InternalControl->Invalidate( false );
  133. }
  134.  
  135.  TPoint   TOWLDelphiControl::ScreenToClient( TPoint pt )
  136. {
  137.   if (InternalControl != NULL)
  138.         InternalControl->ScreenToClient( pt );
  139.   return pt;
  140. }
  141.  
  142.  void   TOWLDelphiControl::SendToBack()
  143. {
  144.   if (InternalControl != NULL)
  145.     InternalControl->SetWindowPos( HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
  146. }
  147.  
  148. void   TOWLDelphiControl::SetBounds( int l, int t, int w, int h )
  149. {
  150.   if (InternalControl != NULL)
  151.     InternalControl->SetWindowPos( NULL, l, t, w, h, SWP_NOZORDER );
  152. }
  153.  
  154.  void  TOWLDelphiControl::SetTextBuf( LPCSTR lpsz )
  155. {
  156.   if (InternalControl != NULL)
  157.     InternalControl->SetWindowText( lpsz );
  158. }
  159.  
  160.  void  TOWLDelphiControl::Show()
  161. {
  162.   if (InternalControl != NULL)
  163.     InternalControl->Show( SW_SHOW );
  164. }
  165.  
  166.  void  TOWLDelphiControl::Update()
  167. {
  168.   if (InternalControl != NULL)
  169.     InternalControl->UpdateWindow();
  170. }
  171.